﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class BM_ZhuanShengBenBMFill : BasePage
{
    string _timeID = string.Empty;
    protected override void Page_LoadAlways()
    {
        base.Page_LoadAlways();
        if (Request.QueryString.Count > 0)
        {
            _timeID = Request.QueryString["TimeID"].ToString().Trim();
            //判断是否超时
            if (Exam.ExamTime_IsTimeOut(_timeID))
            {
                //#region 如果已有报名信息
                //DataTable dt_apply = Exam.ApplyInfo_GetInfo(IDCard, _timeID);
                //if (dt_apply.Rows.Count > 0)
                //{
                //    DataRow dr_apply = dt_apply.Rows[0];
                //    string orderId = dr_apply["OrderID"].ToString();
                //    string sOrderId = security.EncryptQueryString(orderId);
                //    int applyState = int.Parse(dr_apply["ApplyState"].ToString());
                //    if (applyState == 1)
                //    {
                //        //Response.Redirect("BM4.aspx?orderID=" + sOrderId);
                //        Response.Redirect("OrderInfoConfirm.aspx?orderID=" + sOrderId);
                //    }
                //    else if (applyState == 2)
                //    {
                //        Response.Redirect("BM5.aspx?orderID=" + sOrderId);
                //    }
                //}
                //#endregion

            }
            else
                Response.Redirect(BSUtility.mainUrl + "Default.aspx");
        }
        else
        {
            Response.Redirect(BSUtility.mainUrl + "default.aspx");
        }
    }

    protected override void Page_LoadOnce()
    {
        base.Page_LoadOnce();
        DataTable dt = Exam.ExamRank_GetRankName(_timeID);
        if (dt.Rows.Count > 0)
        {
            BSUtility.BindListControl(List_level, dt, "EmRankName", "EmRankName");
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string[] insertValue = new string[] {
                _timeID,
                IDCard,
                EntryIDText.Text.Trim(),
                NationText.Text.Trim(),
                BirthDayText.Text.Trim(),
                PoliText.Text.Trim(),
                BMSchoolText.Text.Trim(),
                MajorNameText.Text.Trim(),
                MajorIDText.Text.Trim(),
                PrizeText.Text.Trim(),
                PointText.Text.Trim(),
                AdressText.Text.Trim(),
                PhoneAddressText.Text.Trim(),
                PostText.Text.Trim(),
            };
            Exam.ZhuanShengBenBMInfo_Save(IDCard, _timeID, List_level.Text, insertValue);
            Response.Redirect("BMInfoConfirm.aspx?TimeID=" + _timeID);
        }
        catch
        { }
    }
}